<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>学成在线在线网页面</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    .w {
      width: 1200px;
      margin: 0 auto;
      padding: 20px;
    }
    
    .box-hd {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      padding-bottom: 10px;
      border-bottom: 1px solid #eee;
    }
    
    .box-hd h3 {
      font-size: 20px;
      color: #333;
    }
    
    .box-hd a {
      color: #666;
      text-decoration: none;
      font-size: 14px;
    }
    
    .box-hd a:hover {
      color: #ff6700;
    }
    
    .box-bd ul {
      list-style: none;
    }
    
    /* 核心浮动样式 */
    .box-bd li {
      float: left;
      width: 290px; /* 计算好的宽度，包含间距 */
      margin-right: 13px;
      margin-bottom: 15px;
      border: 1px solid #eee;
      transition: all 0.3s;
    }
    
    /* 清除每行最后一个元素的右边距 */
    .box-bd li:nth-child(4n) {
      margin-right: 0;
    }
    
    .box-bd li:hover {
      transform: translateY(-5px);
      box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    }
    
    .box-bd img {
      width: 100%;
      height: 180px;
      object-fit: cover;
      display: block; /* 消除图片底部间隙 */
    }
    
    .box-bd h4 {
      padding: 10px;
      font-size: 14px;
      font-weight: normal;
      height: 44px;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
    }
    
    .box-bd a {
      text-decoration: none;
      color: #333;
    }
    
    .info {
      padding: 0 10px 10px;
      font-size: 12px;
      color: #999;
    }
    
    .info span:first-child {
      color: #ff6700;
    }
    
  </style>
</head>
<body>
  <div class="box w">
    <div class="box-hd">
      <h3>精品推荐</h3>
      <a href="#">查看全部</a>
    </div>
    <div class="box-bd">
      <ul class="clearfix">
        <script>

 let data = [
                        {
                            src: 'images/course01.png',
                            title: 'Think PHP 5.0 博客系统实战项目演练',
                            num: 1125
                        },
                        {
                            src: 'images/course02.png',
                            title: 'Android 网络动态图片加载实战',
                            num: 357
                        },
                        {
                            src: 'images/course03.png',
                            title: 'Angular2 大前端商城实战项目演练',
                            num: 22250
                        },
                        {
                            src: 'images/course04.png',
                            title: 'Android APP 实战项目演练',
                            num: 389
                        },
                        {
                            src: 'images/course05.png',
                            title: 'UGUI 源码深度分析案例',
                            num: 124
                        },
                        {
                            src: 'images/course06.png',
                            title: 'Kami2首页界面切换效果实战演练',
                            num: 432
                        },
                        {
                            src: 'images/course07.png',
                            title: 'UNITY 从入门到精通实战案例',
                            num: 888
                        },
                        {
                            src: 'images/course08.png',
                            title: 'Cocos 深度学习你不会错过的实战',
                            num: 590
                        },
                    ]
          // 修复了原代码中的语法错误（多余的}）
          for(let i = 0; i < data.length; i++){
            document.write(`
            <li>
              <a href="#">
                <img src="${data[i].src}" alt="${data[i].title}">
                <h4>${data[i].title}</h4>
                <div class="info">
                  <span>高级</span>·<span>${data[i].num}</span>人在学习
                </div>
              </a>
            </li>
            `);
          }
        </script>
      </ul>
    </div>
  </div>
</body>
</html>
